package chloroform

import argo.jdom._
import argo.format.{JsonFormatter}
import java.io._

/**
 * <p>
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Nov 4, 2010
 * Time: 2:30:45 PM
 */

trait JsonRenderer extends Renderer {
  val formatter: JsonFormatter

  def builder(): JsonNodeBuilder[JsonRootNode]

  def render(outputStream: OutputStream) {
    render(new OutputStreamWriter(outputStream))
  }

  def render(writer: Writer) {
    formatter.format(builder().build, writer)
    writer.flush
  }
}
